package com.cskaoyan.gateway.controller.shopping;


import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.MyCartServcie;
import com.mall.shopping.dto.DeleteCartItemResponse;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController()
@RequestMapping("shopping")
public class ItemsController {

    @Reference(timeout = 2000,retries = 0 , check = false)
    MyCartServcie myCartServcie;

    @DeleteMapping("items/{userId}")
    public ResponseData delectSimple(@PathVariable Integer userId){

        DeleteCartItemResponse deleteCartItemResponse =  myCartServcie.delectSimple(userId);

        return new ResponseUtil<DeleteCartItemResponse>().setData(deleteCartItemResponse);
    }

    @PutMapping("items")
    public ResponseData checkedAll(@RequestBody Map<String,Object> map){

        DeleteCartItemResponse deleteCartItemResponse = myCartServcie.checkedAll(map);

        return new ResponseUtil<DeleteCartItemResponse>().setData(deleteCartItemResponse);
    }

}
